function do_ajax(settings) {
    var opt = {
        async: true,      // 异步模式
        type: 'GET',      // 请求类型
        dataType: 'json', // 返回数据类型
        timeout: 30000,   // 超时时间
        data: '',         // 请求参数
        port: '',         // 请求地址
        call: null        // 回调函数
    };
    $.extend(opt, settings);
    $.ajax({
        async: opt.async,
        type: opt.type,
        timeout: opt.timeout,
        dataType: opt.dataType,
        url: opt.port,
        data: opt.data,
        success: function (result) {
            if (typeof opt.call === 'function') {
                if (result.errcode === 500) {
                    if (result.url === 'refresh') {
                        location.reload();
                    } else if (result.url.length) {
                        location.href = result.url;
                    }
                } else {
                    opt.call(result);
                }
            }
        },
        error: function () {
            if (typeof opt.call === 'function') {
                opt.call({errcode: 2, msg: '网络连接错误，请检查您的网络设置'});
            }
        },
        complete: function (XMLHttpRequest, status) {
            if (status === 'timeout' && typeof opt.call === 'function') {
                opt.call({errcode: 1, msg: '连接超时，请稍后再试'});
            }
        }
    });
}

function listData(option) {
    var init = {
        port: '',
        type: '',
        data: ''
    };
    $.extend(init, option);
    do_ajax({});
}

function valiData(tp, str) {
    var rs;
    switch (tp) {
        case 'mobile':
            partt = /^0?(13[0-9]|14[57]|15[012356789]|166|17[013678]|18[0-9]|19[89])[0-9]{8}$/;break;
        case 'vercode':
            partt = /\d{6}$/;break;
        case 'idcard':
            partt = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;break;
        case 'namecn':
            partt = /^[\u4E00-\u9FA5]{1,6}$/;break;
        case 'email':
            partt = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;break;
    }
    rs = partt.test(str);
    return rs;
}

Date.prototype.Format = function(formatStr)
{
    var str = formatStr;
    var Week = ['日','一','二','三','四','五','六'];

    str=str.replace(/yyyy|YYYY/,this.getFullYear());
    str=str.replace(/yy|YY/,(this.getYear() % 100)>9?(this.getYear() % 100).toString():'0' + (this.getYear() % 100));

    var month = this.getMonth()+1;
    str=str.replace(/MM/,month>9?month.toString():'0' + month);
    str=str.replace(/M/g,this.getMonth());

    str=str.replace(/w|W/g,Week[this.getDay()]);

    str=str.replace(/dd|DD/,this.getDate()>9?this.getDate().toString():'0' + this.getDate());
    str=str.replace(/d|D/g,this.getDate());

    str=str.replace(/hh|HH/,this.getHours()>9?this.getHours().toString():'0' + this.getHours());
    str=str.replace(/h|H/g,this.getHours());
    str=str.replace(/mm/,this.getMinutes()>9?this.getMinutes().toString():'0' + this.getMinutes());
    str=str.replace(/m/g,this.getMinutes());

    str=str.replace(/ss|SS/,this.getSeconds()>9?this.getSeconds().toString():'0' + this.getSeconds());
    str=str.replace(/s|S/g,this.getSeconds());

    return str;
};

Date.prototype.DateAdd = function(strInterval, Number) {
    var dtTmp = this;
    switch (strInterval) {
        case 's' :return new Date(Date.parse(dtTmp) + (1000 * Number));
        case 'n' :return new Date(Date.parse(dtTmp) + (60000 * Number));
        case 'h' :return new Date(Date.parse(dtTmp) + (3600000 * Number));
        case 'd' :return new Date(Date.parse(dtTmp) + (86400000 * Number));
        case 'w' :return new Date(Date.parse(dtTmp) + ((86400000 * 7) * Number));
        case 'q' :return new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + Number*3, dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
        case 'm' :return new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + Number, dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
        case 'y' :return new Date((dtTmp.getFullYear() + Number), dtTmp.getMonth(), dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
    }
};
